The present invention relates generally to the field of data communications, and more particularly, to the field of serial communications bus controllers and microcontrollers that incorporate the same.
CAN (Control Area Network) is an industry-standard, two-wire serial communications bus that is widely used in automotive and industrial control applications, as well as in medical devices, avionics, office automation equipment, consumer appliances, and many other products and applications. CAN controllers are currently available either as stand-alone devices adapted to interface with a microcontroller or as circuitry integrated into or modules embedded in a microcontroller chip. Since 1986, CAN users (software programmers) have developed numerous high-level CAN Application Layers (CALs) which extend the capabilities of the CAN while employing the CAN physical layer and the CAN frame format, and adhering to the CAN specification. CALs have heretofore been implemented primarily in software, with very little hardware CAL support. Consequently, CALs have heretofore required a great deal of host CPU intervention, thereby increasing the processing overhead and diminishing the performance of the host CPU.
Thus, there is a need in the art for a CAN hardware implementation of CAL functions normally implemented in software in order to offload these tasks from the host CPU to the CAN hardware, thereby enabling a great savings in host CPU processing resources and a commensurate improvement in host CPU performance. One of the most demanding and CPU resource-intensive CAL functions is message management, which entails the handling, storage, and processing of incoming CAL/CAN messages received over the CAN serial communications bus and/or outgoing CAL/CAN messages transmitted over the CAN serial communications bus. CAL protocols, such as DeviceNet, CANopen, and OSEK, deliver long messages distributed over many CAN frames, which methodology is sometimes referred to as xe2x80x9cfragmentedxe2x80x9d or xe2x80x9csegmentedxe2x80x9d messaging. The process of assembling such fragmented, multi-frame messages has heretofore required a great deal of host CPU intervention. In particular, CAL software running on the host CPU actively monitors and manages the buffering and processing of the message data, in order to facilitate the assembly of the message fragments or segments into complete messages.
Based on the above and foregoing, it can be appreciated that there presently exists a need in the art for a hardware implementation of CAL functions normally implemented in software in order to offload these tasks from the host CPU, thereby enabling a great savings in host CPU processing resources and a commensurate improvement in host CPU performance.
The assignee of the present invention has recently developed a new microcontroller product, designated xe2x80x9cXA-C3xe2x80x9d, that fulfills this need in the art. The XA-C3 is the newest member of the Philips XA (eXtended Architecture) family of high performance 16-bit single-chip microcontrollers. It is believed that the XA-C3 is the first chip that features hardware CAL support.
The XA-C3 is a CMOS 16-bit CAL/CAN 2.0B microcontroller that incorporates a number of different inventions, including the present invention. These inventions include novel techniques and hardware for filtering, buffering, handling, and processing CAL/CAN messages, including the automatic assembly of multi-frame fragmented messages with minimal CPU intervention, as well as for managing the storage and retrieval of the message data, and the memory resources utilized therefor.
The present invention relates to a CAN microcontroller that supports a plurality (e.g., 32) of message objects, each one of which is assigned a respective message buffer within an on-chip and/or off-chip portion of the overall data memory space of the CAN microcontroller. The location and size of each of the message buffers can be reconfigured by the user (programmer) by simple programming of memory-mapped registers provided for this purpose. The message buffers are used to store incoming (receive) messages and to stage outgoing (transmit) messages. With the XA-C3 microcontroller that constitutes a presently preferred implementation of the present invention, Direct Memory Access (DMA) is employed to enable the XA-C3 CAN module to directly access any of the 32 message buffers without interrupting the processor core. This message storage scheme provides a great deal of flexibility to the user, as the user is free to use as much or as little message storage area as an application requires, and is also free to position the message buffers wherever it is most convenient.
This message storage scheme is a key element of the unique xe2x80x9cmessage managementxe2x80x9d capabilities of the XA-C3 CAN microcontroller, as this scheme enables the XA-C3 CAN/CAL module to concurrently assemble many (up to 32) incoming, fragmented messages of varying lengths, and, at the same time, stage multiple outgoing messages for tansmission. Since incoming message assembly is handled entirely in hardware, the processor is free to perform other tasks, typically until a complete message is received and ready for processing.
All CAN devices have the ability to perform receive acceptance filtering or screening. Acceptance filtering is typically accomplished by comparing information in the header portion of a received CAN message to be filtered or screened (and, in some cases, also the first and/or second byte in the data field of the received CAN message) to one or more pre-established values, sometimes called acceptance filters or screeners. Software running on the processor core can perform the acceptance filtering at the expense of performance, because software requires an ample amount of CPU resources and time to perform acceptance filtering. Therefore, hardware filtering is desired in order to reduce the burden or overhead processing load on the CPU (processor core). However, with the presently available technology, hardware filtering is far less flexible than software filtering, and greatly increases the required die area for implementation of the CAN device.
The presently available acceptance filtering techniques include the use of a match field and a mask field to create what is sometimes referred to as a xe2x80x9cmatch and maskxe2x80x9d filter. Each combination of available match and mask fields constitutes a separate filter or filter object. A basic CAN device will typically have one or two filters with full match and mask capabilities. A whole family of messages will typically be accepted. Software or hardware can be employed to actually perform the filtering. However, with the presently available technology, software must decide where to store each individual message. This type of filtering is generally the most flexible; however, it consumes the most CPU resources.
A full CAN device is one in which the hardware filters a message and matches it to one of a number of screeners to decide where to store the message. Each filter is linked to a message buffer. Upon a successful comparison of the incoming message header to one of the screeners, the message is stored in the message buffer associated with the matching screener. Generally, only xe2x80x9cmatchingxe2x80x9d and not xe2x80x9cmaskingxe2x80x9d is performed by each filter. However, there could be a xe2x80x9cglobal maskxe2x80x9d that is applied to all filters, or one filter could be designated to provide the xe2x80x9cmaskxe2x80x9d.
Based on the above and foregoing, it can be appreciated that there presently exists a need in the art for a much more flexible and powerful technique for message acceptance filtering in a CAN device, e.g., a CAN microcontroller, that overcomes the above-discussed limitations and shortcomings of the presently available technology, particularly such a technique that does not explode the required die area to implement the CAN device, and which is performed in hardware, rather than software, to thereby minimize loading of the processor (CPU) core, and thereby dramatically improve system performance.
The present invention fulfills this need in the art. As will become apparent hereinafter, the preferred implementation of the present invention in the XA-C3 microcontroller provides 32 fully programmable match and mask filters, which affords a much more powerful system than is possible with the presently available technology, without loading the processor core. The user can define and dedicate filters to a wide variety of messages without running out. This is especially useful for systems that need to dedicate filters to system management functions, such as unconnected message management, explicit I/O and Dup MAC used in the CAN protocol DeviceNet.
Most existing CAN devices can filter on an 11-bit CAN identifier (standard CAN frames) or a 29-bit CAN identifier (extended CAN frames). However, each of the 32 filters in the XA-C3 microcontroller can be individually configured to filter on either the 11-bit CAN identifier of standard CAN frames or the 29-bit CAN identifier of extended CAN frames. This allows for a system with mixed CAN devices and provides maximum flexibility.
Further, the XA-C3 microcontroller provides filtering that goes beyond the CAN specification. More particularly, in addition to filtering on the CAN identifier, the XA-C3 microcontroller permits filtering on the first and/or second data bytes of the data field of incoming CAN frames. This is a very useful feature for higher level CAN protocols such as DeviceNet, CanOpen, and Osek, which have traditionally required software to filter on the first two bytes of the data field.
Yet further, the XA-C3 microcontroller provides for masking on every bit on every filter (with the exception of the IDE bit). Traditional CAN devices have only provided a subset of this capability, allowing only global masking which is applied to all of the filter objects, or dedicating one or two objects to have the fully masking capability. No presently available device provides for full masking on every filter. This feature is extremely useful to a user that wants to define and receive families of messages under both the standard CAN specification and the higher level protocols such as DeviceNet, CanOpen, and Osek.
Additionally, the XA-C3 microcontroller provides for masking on the RTR bit in the CAN header, thereby allowing the device to receive and recognize an RTR frame. In this connection, the user can dedicate a filter object exclusively for the purpose of monitoring an RTR frame and/or sending out RTR frames.
The present invention encompasses, in one of its aspects, a CAN device that supports a plurality n (where nxe2x89xa73) of message objects, including a plurality of registers associated with each message object, including at least one object match ID register that contains a multi-bit object match ID field, and at least one object mask register that contains a multi-bit object mask field; and, a CAN/CAL module that processes incoming messages. The CAN/CAL module assembles a multi-bit screener ID from selected bits of each incoming message to be acceptance filtered, compares the bits comprising the screener ID with corresponding bits of the object match ID field associated with each of at least designated ones of the plurality n of message objects, disregarding any bits of each object match ID field that are masked by corresponding bits of the associated object mask field, and then determines whether any of the comparisons results in a match. Any selected one or more bits of the object match ID field associated with each of the plurality n of message objects can be set to xe2x80x981xe2x80x99 or xe2x80x980xe2x80x99, and any selected one or more bits of the object mask field associated with each of the plurality n of message objects can be set to xe2x80x981xe2x80x99 or xe2x80x980xe2x80x99 in order to mask any selected one or more bits of the associated object match ID field, whereby the combination of the object match ID field and the object mask field associated with each of the plurality n of message objects constitutes a fully programmable match and mask filter. The CAN/CAL module has the capability to perform acceptance filtering on incoming messages constituting either standard or extended CAN frames. If more than one match is detected, a lowest-numbered (or, alternatively, highest-numbered) one of the message objects is designated to be the matching message object.
In a presently preferred embodiment, the plurality of registers further include an RTR register associated with each message object. The RTR register associated with each message object contains an RTR handling enable field that is programmable for the purpose of enabling or disabling the associated message object to detect receipt of an incoming message that constitutes an Remote Transmit Request frame and/or to transmit a Remote Transmit Request frame. Preferably, an incoming message for which a match is detected is stored by a DMA engine in the message buffer associated with the matching message object.
In another of its aspects, the present invention encompasses a CAN microcontroller that includes, in addition to the above-described registers (which are preferably implemented as memory-mapped registers in the microcontroller data memory space) and the above-described CAN/CAL module, a processor core that runs CAN applications, and a DMA engine that enables the CAN/CAL module to directly access the message buffers, e.g., for storage and retrieval of messages.
In yet another of its aspects, the present invention encompasses, in a CAN device that supports a plurality n (where nxe2x89xa73) of message objects each of which has an associated message buffer, at least one associated match ID register, and at least one associated mask register, a method for acceptance filtering incoming CAN frames. The method includes the steps of programming the at least one match ID register associated with each of at least designated ones of the message objects by selectively setting each of the bits in a multi-bit match ID field contained therein to xe2x80x981xe2x80x99 or xe2x80x980xe2x80x99; programming the at least one mask register associated with each of the at least designated ones of the message objects by selectively setting each of the bits in a multi-bit mask field contained therein to xe2x80x981xe2x80x99 or xe2x80x980xe2x80x99; extracting a multi-bit screener ID field from a received CAN frame; and, comparing the extracted screener ID field to the multi-bit match ID field stored in the at least one match ID register associated with each of the at least designated ones of the message objects, excluding from the comparison any bits of the match ID field masked by corresponding bits of the associated mask field stored in the at least one associated mask register. If a match if found as a result of the comparing step, the method further includes the step of storing data bytes of the received CAN frame in the message buffer associated with the matching message object.